from llama_index.core import download_loader


# 安装数据库依赖  pip install llama_index.readers.database
from llama_index.readers.database import DatabaseReader
import os

reader = DatabaseReader(
    scheme="mysql",
    host="localhost",
    port="3306",
    user=os.getenv("LOCAL_MYSQL_USER"),
    password=os.getenv("LOCAL_MYSQL_PASSWORD"),
    dbname="llama-index", # 数据库名称
)

query = "SELECT * FROM eb_user"
documents = reader.load_data(query=query)
print(documents)